home *** CD-ROM | disk | FTP | other *** search
- Path: rznews.rrze.uni-erlangen.de!news
- From: elmar.vogt@rzmail.uni-erlangen.de (Elmar Vogt)
- Newsgroups: comp.lang.c++
- Subject: Re: A question of (lexical) style
- Date: 6 Mar 1996 12:29:41 GMT
- Organization: LUR, University of Erlangen.
- Message-ID: <4hk0fl$irl@rznews.rrze.uni-erlangen.de>
- References: <313c99bc.0@193.89.47.9>
- NNTP-Posting-Host: faust207.lstm.uni-erlangen.de
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- In article <313c99bc.0@193.89.47.9>, elgaard@dk-online.dk says...
- >
- >A question of (lexical) style
- >
- >I am currently writing guidelines for C++ programmers, and I am in doubt
- about h
- >ow to place * and & in declarations.
- >
-
- I fully agree that there is no universal 'right' or 'wrong' style, just
- taste.
-
- My personal convention is, founded on the (rough) equivalence of asterisks
- and brackets:
- If variable _bar_ of type _foo_ is to be considered an array, I will write
- foo *bar;
-
- If _bar_ is a pointer to a _foo_ instance, it's
- foo* bar;
-
- This notation appears to be more logical to me, since -logically, not
- grammatically- in the first case, if I want to use a _bar_ element, I
- usually write
- bar[i]=...;
- thus exchanging '*' and '[]' in a loose manner, and considering both a
- part of _bar_'s _name_, instead of _type_.
- Obviously, if bar is just a pointer, I can't simply write bar[i]. Would
- its name be written _*bar_, I would more easily be mislead to believe I
- could write bar[i].
-
- It's just I once consider the asterisk a part of the name, when it's
- really an array, and once a part of the type, when it's a pointer.
-
- Does this sound plausible?
-
- Elmar
-
- --
- --
- /----------------------------------------------------------------\
- | Elmar Vogt : MS->PhD | voice: (+49)9131/761-207; fax: ...-202 |
- | LUR, Schottkystr. 10 |http://www.rrze.uni-erlangen.de/~iwur08/ |
- |University of Erlangen| Elmar.Vogt@rzmail.uni-erlangen.de |
- |91058 Erlangen-Germany| Vogt@nt.e-technik.uni-erlangen.de |
- |-------- VIS VISCERIS, NON FERRO FERTUR (T. Doom) --------------|
- |SCA: Agilmar von Sevelingen; Fencing, Calligraphy, Jewelry, Food|
- \----------------------------------------------------------------/
-
-